package typejump.engine;

import java.awt.geom.Rectangle2D;

/**
 * Holds position, size, and velocity.
 * @author g
 *
 */
public class RBounds implements BoundsInfo {
	protected volatile double vx = 0;
	protected volatile double vy = 0;
	protected Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, 1, 1);
	
	// Dimension setters/getters
	public double width() { return rect.width; }
	public double height() { return rect.height; }
	public void width(double d) { rect.width = d; }
	public void height(double d) { rect.height = d; }
	
	// Convenience getters
	public double left() { return rect.x; }
	public double right() { return rect.x+rect.width; }
	public double top() { return rect.y; }
	public double bottom() { return rect.y+rect.height; }
	public double centerX() { return rect.x + rect.width/2; }
	public double centerY() { return rect.y + rect.height/2; }
	
	// Convenience setters
	public void left(double d) { rect.x = d; }
	public void right(double d) { rect.x = d - rect.width; }
	public void top(double d) { rect.y = d; }
	public void bottom(double d) { rect.y = d -rect.height; }
	public void centerX(double d) { rect.x = d - rect.width/2; }
	public void centerY(double d) { rect.y = d - rect.height/2; }
	
	// Convenience ints
	public int ix() { return (int)rect.x; }
	public int iy() { return (int)rect.y; }
	public int iw() { return (int)rect.width; }
	public int ih() { return (int)rect.height; }
	
	// Velocity methods
	public double vx() { return vx; }
	public double vy() { return vy; }
	public void vx(double d) { this.vx = d; }
	public void vy(double d) { this.vy = d; }
	

	public void set(RBounds other) {
		left(other.left());
		top(other.top());
		width(other.width());
		height(other.height());
		vx(other.vx());
		vy(other.vy());
	}
}
